<template>
  <div>
    <input type="text" name="" id="" v-model="form.bookname">
    <input type="text" name="" id="" v-model="form.author">
    <input type="text" name="" id="" v-model="form.publisher">
    <button @click="addfn">添加</button>
  </div>
</template>

<script>
import axios from 'axios'
axios.defaults.baseURL = 'http://123.57.109.30:3006'
export default {
  data () {
    return {
      form: {
        bookname: '',
        author: '',
        publisher: ''
      }
    }
  },
  created () {
    axios({
      url: '/api/getbooks'
    }).then(res => {
      console.log(res)
    })
  },
  methods: {
    addfn () {
      axios({
        url: '/api/addbook',
        method: 'post',
        data: {
          appkey: '7250d3eb-18e1-41bc-8bb2-11483665535a',
          ...this.form
        }
      }).then(res => { console.log(res) })
    }
  }
}
</script>

<style>

</style>
